var e = require;
var t = module;
var n = exports;
("use strict");
var o,
  i =
    (this && this.__extends) ||
    ((o = function (e, t) {
      return (o =
        Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array &&
          function (e, t) {
            e.__proto__ = t;
          }) ||
        function (e, t) {
          for (var n in t)
            Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
        })(e, t);
    }),
      function (e, t) {
        function n() {
          this.constructor = e;
        }
        o(e, t),
          (e.prototype =
            null === t
              ? Object.create(t)
              : ((n.prototype = t.prototype), new n()));
      }),
  r =
    (this && this.__decorate) ||
    function (e, t, n, o) {
      var i,
        r = arguments.length,
        y =
          r < 3
            ? t
            : null === o
              ? (o = Object.getOwnPropertyDescriptor(t, n))
              : o;
      if ("object" == typeof Reflect && "function" == typeof Reflect.decorate)
        y = Reflect.decorate(e, t, n, o);
      else
        for (var a = e.length - 1; 0 <= a; a--)
          (i = e[a]) &&
            (y = (r < 3 ? i(y) : 3 < r ? i(t, n, y) : i(t, n)) || y);
      return 3 < r && y && Object.defineProperty(t, n, y), y;
    };
Object.defineProperty(n, "__esModule", { value: !0 });
var y,
  a = e("BaseUI"),
  s = e("EventConst"),
  c = e("PlatformConst"),
  x = e("PopupConst"),
  l = e("UserConst"),
  h = e("EventManager"),
  d = e("PlatformManager"),
  u = e("PopupManager"),
  f = e("TipManager"),
  p = e("UserManager"),
  g = e("XMADUtils"),
  t = cc._decorator,
  e = t.ccclass,
  e =
    (t.property,
      (y = a.default),
      i(m, y),
      (m.prototype.onLoad = function () {
        y.prototype.onLoad.call(this),
          cc.game.on("addInf", this.clickVideo, this),
          this.addBtnOn("giveUpBtn", this.clickGiveUp, this),
          this.addBtnOn("defineBtn1", this.clickGiveUp, this),
          this.addBtnOn("videoBtn", this.clickVideo, this),
          this.initView();
      }),
      (m.prototype.onEnable = function () {
        console.error("体力特权: ", d.Platform, c.EPlatform.XIAOMI_ANDROID);
        // d.Platform.is(c.EPlatform.XIAOMI_ANDROID)
        //   ? g.XMAD.showBannerFeed()
        //   : d.Platform.showBanner();
        // d.Platform.showBanner();
        window.__prv.doAction(4, ['ks']);
        //@ts-ignore
        window.__prv.doAction(1, ['ks5']);
        window.__prv.doAction(1, ['oppo']);
        window.__prv.doAction(1, ['vivo']);
        window.__prv.doAction('二级界面弹出插屏', ['hw']);
      }),
      (m.prototype.onDisable = function () {
        d.Platform.hideBanner();
      }),
      (m.prototype.initView = function () {
        var e = p.User.get(l.UserData.INF_POWER_VIDEO_TIMES) || 0;
        p.User.set(l.UserData.INF_POWER_VIDEO_TIMES, e),
          (this.dict.amount.getComponent(cc.Label).string =
            "下一等级：V" + (e + 1)),
          (this.dict.range.getComponent(cc.Sprite).fillRange = e / 3);
      }),
      (m.prototype.clickGiveUp = function () {
        u.Popup.hide(),
          p.User.getTempData(l.TempData.POWER_TYPE) ||
          (cc.game.emit("gamelog", "page009"),
            setTimeout(function () {
              u.Popup.show(x.PopupConst.POWER_SHORTAGE);
            }, 300));
      }),
      (m.prototype.clickVideo = function () {
        var n = this;
        cc.game.emit("gamelog", "btn026")
        if (cc.find("content/New Node/videoBtn/icon_sp02", this.node).active) {
          window.__prv.showVideo(function () {
            var t;
            1 == 1 &&
              (console.log("成功"),
                cc.game.emit("gamelog", "rewarde_btn007"),
                (t = p.User.get(l.UserData.INF_POWER_VIDEO_TIMES) + 1),
                p.User.set(l.UserData.INF_POWER_VIDEO_TIMES, t),
                n.initView(),
                0 < 3 - t
                  ? ((e = p.User.get(l.UserData.POWER)),
                    p.User.set(l.UserData.POWER, e + 10 * t),
                    f.Tip.show("体力+" + 10 * t),
                    h.Event.emit(s.default.POWER_EFFECT, !0))
                  : (f.Tip.show("已开启无限体力模式"),
                    p.User.setTempData(l.TempData.IS_INFINITE_POWER, !0),
                    h.Event.emit(s.default.UPDATE_INFINITE_POWER, !0),
                    p.User.set(
                      l.UserData.INF_POWER_START_TIME,
                      new Date().getTime()
                    ),
                    u.Popup.hide()));
          });
        } else {
          var t;
          1 == 1 &&
            (console.log("成功"),
              cc.game.emit("gamelog", "rewarde_btn007"),
              (t = p.User.get(l.UserData.INF_POWER_VIDEO_TIMES) + 1),
              p.User.set(l.UserData.INF_POWER_VIDEO_TIMES, t),
              n.initView(),
              0 < 3 - t
                ? ((e = p.User.get(l.UserData.POWER)),
                  p.User.set(l.UserData.POWER, e + 10 * t),
                  f.Tip.show("体力+" + 10 * t),
                  h.Event.emit(s.default.POWER_EFFECT, !0))
                : (f.Tip.show("已开启无限体力模式"),
                  p.User.setTempData(l.TempData.IS_INFINITE_POWER, !0),
                  h.Event.emit(s.default.UPDATE_INFINITE_POWER, !0),
                  p.User.set(
                    l.UserData.INF_POWER_START_TIME,
                    new Date().getTime()
                  ),
                  u.Popup.hide()));
        }

      }),
      r([e], m));
function m() {
  return (null !== y && y.apply(this, arguments)) || this;
}
n.default = e;
